function p = pathlist(R)
%PATHLIST Summary of this function goes here
%   Detailed explanation goes here

% PATHLIST(R) Returns path R or current path as a cell array. The delimiter is the value
% returned by the pathsep function.
% USAGE: p = pathlist(genpath);

% Initialize to the current path.
if nargin < 1
    R = path;
end

% Remove trailing path separator, if any.
if ~isempty(R)
    if isequal(R(end), pathsep)
        R = R(1:end-1);
    end
end

p = strread(R, '%s', 'delimiter', pathsep); % Use generic parse function. 
